package com.unity.bh3.model;

import lombok.Data;

@Data
public class ChatMessage {
    private String type;        // 消息类型：CHAT, JOIN, LEAVE, ROOM_CHANGE
    private String roomId;      // 房间ID
    private String senderId;    // 发送者ID
    private String content;     // 消息内容
    private long timestamp;     // 时间戳
    
    // 用户信息
    private String nickname;    // 用户昵称
    private String avatar;      // 用户头像URL
    
    // 房间信息
    private int roomUserCount;  // 房间人数
    private boolean isCurrentUser; // 是否为当前用户的消息
    
    public static ChatMessage createChatMessage(String roomId, String senderId, String nickname, 
            String avatar, String content, boolean isCurrentUser) {
        ChatMessage message = new ChatMessage();
        message.setType("CHAT");
        message.setRoomId(roomId);
        message.setSenderId(senderId);
        message.setNickname(nickname);
        message.setAvatar(avatar);
        message.setContent(content);
        message.setTimestamp(System.currentTimeMillis());
        message.setCurrentUser(isCurrentUser);
        return message;
    }
    
    public static ChatMessage createSystemMessage(String type, String roomId, String senderId, 
            String content, int roomUserCount) {
        ChatMessage message = new ChatMessage();
        message.setType(type);
        message.setRoomId(roomId);
        message.setSenderId(senderId);
        message.setContent(content);
        message.setTimestamp(System.currentTimeMillis());
        message.setRoomUserCount(roomUserCount);
        message.setNickname("系统");
        message.setAvatar("/images/system-avatar.png");
        return message;
    }
} 